package net.minecraft.src;

import java.util.Random;

public class PPHGenWaterCalamites extends WorldGenerator
{

    public PPHGenWaterCalamites()
    {
    }

    public boolean generate(World world, Random random, int i, int j, int k)
    {
	if(world.getBlockId(i, j - 1, k) == mod_pph.prehistoricDirt.blockID && world.getBlockMaterial(i, j, k) == Material.water && world.isAirBlock(i, j + 4, k) && world.isAirBlock(i, j + 12, k))
	{
		for(int width = 0; width < 1; width++)
		{
			for(int height = 0; height < 24; height++)
			{
				for(int depth = 0; depth < 1; depth++)
				{
					world.setBlockAndMetadata(i+width, j+height, k+depth, mod_pph.prehistoricWood.blockID, 1);
					world.setBlockAndMetadata(i+width, j+height+1, k+depth, mod_pph.prehistoricLeaves.blockID, 1);
				}
			}
		}	
		generateLeaves(world, random, i, j + 23, k, -1, 2);
		generateLeaves(world, random, i, j + 21, k, -1, 2);
	}
		return true;
	}
	
	private boolean generateLeaves(World world, Random random, int i, int j, int k, int i1, int j1)
	{
	for(int width = i1; width < j1; width++)
	{
		for(int height = 0; height < 1; height++)
		{
			for(int depth = i1; depth < j1; depth++)
			{
			if(world.isAirBlock(i+width, j+height, k+depth))
			{
				world.setBlockAndMetadata(i+width, j+height, k+depth, mod_pph.prehistoricLeaves.blockID, 1);
			}
		}
	}
	if(world.getBlockId(i, j - 14, k) == mod_pph.prehistoricWood.blockID && world.getBlockMetadata(i, j - 10, k) == 1)
	{
		generateLeaves(world, random, i, j - 4, k, i1 - 1, j1 + 1);
	}
	}
		return true;
	}
}